#pragma once

#include "LionSingleton.h"
#include "LionFrameListener.h"
#include "LionActor.h"
#include "LionMesh.h"
#include "CameraProxy.h"
#include "Components/LionRenderWindowComponent.h"
#include "GridMesh.h"


class EDRoot : public Lion::Singleton<EDRoot>, public Lion::FrameListener
{
public:
    enum MouseButton
    {
        NoneButton = 0x00,
        LeftButton = 0x00000001,
        RightButton = 0x00000002,
        MiddleButton = 0x00000004, // ### Qt 6: remove me
    };

protected:
    EDGridMesh* m_pGridMesh;
    Lion::Actor* m_pRenderWindowActor;
    Lion::RenderWindowComponent* m_pMainCameraComponent;
    Lion::MeshPtr m_meshBox;
    Lion::Actor* m_pActor;
    Lion::Actor* m_pActor2;
    Lion::Actor* m_pActor3;
    Lion::Actor* m_pActorGlobal;
    Lion::Actor* m_pActorPerspectiveDecal;
    Lion::Actor* m_pActorDirectLight;
    CameraProxy m_mainCamera;

    Lion::s32 m_cursorX;
    Lion::s32 m_cursorY;
    Lion::s32 m_cursorZ;
    Lion::f32 m_fovx;

public:
    EDRoot();
    ~EDRoot();

    bool initialize();

    bool initWindow(Lion::u64 windowId, Lion::s32 width, Lion::s32 height);

    bool createGame();

    void renderOneFrame();

    // see FrameListener
    virtual bool frameStarted();
    virtual bool frameEnd();

    void fireMousePress(Lion::s32 x, Lion::s32 y, MouseButton button);
    void fireMouseRelease(Lion::s32 x, Lion::s32 y, MouseButton button);
    void fireMouseMove(Lion::s32 x, Lion::s32 y, Lion::s32 z, MouseButton button);
    void fireMouseWheel(Lion::f32 x, Lion::f32 y);
    void fireKeyPress(Lion::s32 virtual_key_codes);
    void fireKeyRelease(Lion::s32 virtual_key_codes);

     void fireScreenResize(Lion::u32 width, Lion::u32 height);

//     void FBXImport(const stringc& path, const stringc& savePath);
// 
//     void loadDirectory(const c8* name);
};